
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>留学生管理系统</title>
        <link rel="stylesheet" href="${path}/css/admin2.css">
        <link rel="stylesheet" href="${path}/css/coursemanage-kb.css">
        <style>
            #above-mask table th{
                width: 5%;
            }
            #above-mask table td{
                width: 10%;
            }
            #currentTermContainer a:hover{
                text-decoration: underline;
                color: orange;
            }
           #courseName-modal{
               position: relative;
    			margin: -500px auto 0;
                padding: 10px;
                width: 600px;
    			z-index: 4000;
    			background: #fff;
            }
            #handle-modal{
               position: relative;
    			margin: -500px auto 0;
                padding: 20px;
                width: 260px;
    			z-index: 4000;
    			background: #fff;
            }
            
        </style>
        <script>
            var _current_item = "#adminCourseManage";
        </script>
        <script type="text/javascript" src="${path}/js/jquery.min.js"></script>
    </head>
    <body>
        <div id="above-mask">
            <div id="kb-container" class="hide pannel">
                <div class="close-container"><a class="close" onclick="$('#select2').html('');$('#select3').html(''); hide('#above-mask, #mask, #kb-container, #courseName-modal,#editkbpanel,#addkspanel');">×</a></div>
                <div id="editkbpanel"></div>
                <div id="addkspanel"></div>
                <div id="kbtable" class="clearfix"></div>
                
            </div>
            
            <!-- <div class="pannel hide" id="courseName-modal">
            	<form action="${path}/adminStuExport/exportCouStuExcel" method="post">
                <div class="close-container">
                    <a class="close" onclick="hide('#courseName-modal')">&times;</a>
                </div>
                    <table id="payTab">			
                        <tr>
                            <td ><br /> 编号 <select id="stuName" name="uuid" style="width:470px">
                                </select><br /><br />
                    		<button style="margin-left:30px" onclick="hide('#courseName-modal');exportName()">导出</button></td>
                        </tr>
                    </table>
                </form>
            </div> -->
            <!-- 操作面板 -->
               <div class="pannel hide" id="handle-modal">
            	
                <div class="close-container">
                    <a class="close" onclick="hide('#handle-modal')">&times;</a>
                </div>
                    <table id="handle">			
                        <tr>
                            <td ><form action="${path}/adminStuExport/exportCouStuExcel" method="post">
                            <button id="stuName" name="uuid" class="cancel" style="width:80%" onclick="exportName()">课程名单导出</button></form>
                    		<button style="width:80%" onclick="hide('#handle-modal');editCourse();showeditkbpanel();">修改课程</button>
                    		<button style="width:80%" onclick="hide('#handle-modal');$('#select2').html('');hide('#editkbpanel');showaddkspanel();">新建课时</button>
                    		<button class="delete" style="width:80%" onclick="hide('#handle-modal');deleteCourse();hide('#editkbpanel');$('#select2').html('');">删除课程</button></td>
                        </tr>
                    </table>
            </div>
            <!-- 操作面板 -->
            <!--newkb-->
            <div id="newkb-container" class="hide" style="height:510px;">
                <div class="newkb pannel">
                    <div class="close-container"><a class="close" onclick="hide('#newkb-container');$('#select1').html('')">×</a></div>
                    <table>
                        <tr>
                            <th style="text-align:left;"><div>学院</div>
                            </th>
                            <td style="text-align:left;">
                                <select id="collegeCode" style="width:300px" onchange="lookCourse();">
                                    <#if college?exists>
                                    <#list college as r> 
                                    <option value="${r.collegeCode!}">${r.collegeCode!}-${r.collegeName!}</option>
                                    </#list>
                                    </#if>	
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th style="text-align:left;"><div>课程名</div>
                            </th>
                            <td style="text-align:left;">
                                <select id="courseName" style="width:300px">
                                <option selected></option>
                                    <#if course?exists>
                                    <#list course as r> 
                                    <option value="${r.courseNo!}">${r.courseName!}</option>
                                    </#list>
                                    </#if>	
                                </select>
                            </td>
                        </tr>
                        <tr><th style="text-align:left;"><div>星期</div></th><td style="text-align:left;"><select id="week" style="width:100px">
                                    <option>星期一</option>
                                    <option>星期二</option>
                                    <option>星期三</option>
                                    <option>星期四</option>
                                    <option>星期五</option>
                                </select></td></tr>

                        <tr><th style="text-align:left;"><div>节次</div></th><td style="text-align:left;">
                                第一节课 <select id="firstClass">
                                    <option>1</option><option>2</option><option>3</option>
                                    <option>4</option><option>5</option><option>6</option>
                                    <option>7</option><option>8</option><option>9</option>
                                    <option>10</option><option>11</option><option>12</option>
                                </select>  
                                最后一节课 <select id="lastClass">
                                    <option>1</option><option>2</option><option>3</option>
                                    <option>4</option><option>5</option><option>6</option>
                                    <option>7</option><option>8</option><option>9</option>
                                    <option>10</option><option>11</option><option>12</option>
                                </select></td></tr>

                        <tr><th style="text-align:left;"><div>周次</div></th><td style="text-align:left;">
                                起始周 <select id="firstWeek">
                                    <option>1</option><option>2</option><option>3</option>
                                    <option>4</option><option>5</option><option>6</option>
                                    <option>7</option><option>8</option><option>9</option>
                                    <option>10</option><option>11</option><option>12</option>
                                    <option>13</option><option>14</option><option>15</option>
                                    <option>16</option><option>17</option><option>18</option>
                                </select>  
                                结束周 <select id="lastWeek">
                                    <option>1</option><option>2</option><option>3</option>
                                    <option>4</option><option>5</option><option>6</option>
                                    <option>7</option><option>8</option><option>9</option>
                                    <option>10</option><option>11</option><option>12</option>
                                    <option>13</option><option>14</option><option>15</option>
                                    <option>16</option><option>17</option><option>18</option>
                                </select>  </td></tr>

                        <tr><th style="text-align:left;"><a style="text-decoration:underline;color:#006699" onclick="createDatatable(_select + '.ter_1'); show('#select1 .teacher');">教师</a></th><td id="selectteacher1"></td></tr>
                        <tr><th style="text-align:left;"><a style="text-decoration:underline;color:#006699" onclick="createDatatable(_select + '.ass_1'); show('#select1 .assistant');">助教</a></th><td id="selectassistant1"></td></tr>
                        <tr><th style="text-align:left;"><a style="text-decoration:underline;color:#006699" onclick="createDatatable(_select + '.loc_1'); decorateTd(_select + '.loc_1'); show('#select1 .location');">教室</a></th><td id="selectclassroom1"></td></tr>
                        <tr><th style="text-align:left;"><a style="text-decoration:underline;color:#006699" onclick="createDatatable(_select + '.stu_1'); show('#select1 .student');makeStringToDictS(this.parentNode.parentNode.lastChild.lastChild.value,this.parentNode.parentNode.lastChild.firstChild.innerHTML);">学生</a><span id="count1"></span></th><td><div id="selectstudent1"></div><input type="hidden" id="stu1PassportNo"></td></tr>
                        <tr><th><div></div></th><td><button id="k1" onclick="newCourse();hide('#newkb-container');$('#select1').html('')">确定</button></td></tr>
                    </table>
                </div>
                <div id="select1"></div>
            </div>
        </div>
        <!--newkb end-->
        <div class="hide">
            <!--teacher-->
            <div id="teacher" class="teacher hide pannel">
                <div class="close-container"><a class="close" onclick="hide('#teacher')">×</a></div>
                <div>
                    <span>学院</span>
                    <select onchange="lookTeacher();" id="college">
                        <#if college?exists>
                        <#list college as r> 
                        <option value="${r.collegeCode!}">${r.collegeCode!}-${r.collegeName!}</option>
                        </#list>                                             
                        </#if>	                       
                    </select>

                    <table class="ter_1">
                        <thead>
                            <tr>
                                <td><input type="checkbox" id="checkteacher" onclick="checkAll(this, _select + '.ter_1')"></td> 
                                <td>工号</td>
                                <td>姓名</td>
                                <td>学院</td> 
                                <td>职称</td>
                            </tr>
                        </thead>
                        <tbody>

                            <#if teacher?exists>
                            <#list teacher as r>
                            <tr>
                                <td><input type="checkbox" value="${r.tName}" id="teacherCheck${r_index}" name="teacherCheck" onchange="alertTer(this)"></td>
                                <td>${r.tNo}</td>
                                <td>${r.tName}</td>
                                <td>${r.collegeName}</td>
                                <td>${r.title}</td>
                            </tr>
                            </#list>
                            </#if>
                        </tbody>
                    </table>
                    <button onclick="getParam(_select + '.ter_1', _selectteacher);hide('#teacher');">确定</button>
                </div>
            </div>
            <!--teach end-->
            <!--assistant-->
            <div id="assistant" class="assistant hide pannel">
                <div class="close-container"><a class="close" onclick="hide('#assistant')">×</a></div>
                <div>
                    <span>学院</span>
                    <select onchange="lookAssistant();" id="as_college">
                        <#if college?exists>
                        <#list college as r> 
                        <option value="${r.collegeCode!}">${r.collegeCode!}-${r.collegeName!}</option>
                        </#list>                                             
                        </#if>	                       
                    </select>

                    <table class="ass_1">
                        <thead>
                            <tr>
                                <td><input type="checkbox" id="checkassistant" onclick="checkAll(this, _select + '.ass_1')"></td> 
                                <td>工号</td>
                                <td>姓名</td>
                                <td>学院</td> 
                                <td>职称</td>
                            </tr>
                        </thead>
                        <tbody>

                            <#if teacher?exists>
                            <#list teacher as r>
                            <tr>
                                <td><input type="checkbox" value="${r.tName}" id="assistantCheck${r_index}" name="assistantCheck"></td>
                                <td>${r.tNo}</td>
                                <td>${r.tName}</td>
                                <td>${r.collegeName}</td>
                                <td>${r.title}</td>
                            </tr>
                            </#list>
                            </#if>
                        </tbody>
                    </table>
                    <button onclick="getParam(_select + '.ass_1', _selectassistant);hide('#assistant');">确定</button>
                </div>
            </div>
            <!--assistant end-->
            <!--location-->
            <div id="location" class="location hide pannel">
                <div class="close-container"><a class="close" onclick="hide('#location');">×</a></div>
                <div class="modal-body">
                    <span>教室类型</span>
                    <select onchange="lookClassroom();" id="classroomType" name="classroomType">
                            <#if classroomType?exists>
                            <#list classroomType as ct>
                            <option value="${ct.classroomType}">${ct.classroomType}</option>
                            </#list>
                            </#if>
                    </select>

                    <table class="loc_1">
                        <thead>
                            <tr>
                                <td></td> 
                                <td>教室编号</td>
                                <td>教室容量</td>
                                <td>考试容量</td> 
                                <td>教室类型</td>
                            </tr>
                        </thead>
                        <tbody>
                            <#if classroom?exists>
                            <#list classroom as r>
                            <tr>
                                <td><input type="radio" value="${r.classroomNo}" id="classroomCheck${r_index}" name="classroomCheck"></td>
                                <td>${r.classroomNo}</td>
                                <td>${r.classroomVolume}</td>
                                <td>${r.examVolume}</td>
                                <td>${r.classroomType}</td>
                            </tr>
                            </#list>
                            </#if>
                        </tbody>
                    </table>
                    <button onclick="getParam(_select + '.loc_1', _selectclassroom);hide('#location');">确定</button>
                </div>
            </div>
            <!--location end-->
            <!--student-->
            <div id="student" class="student hide pannel">
                <div>
                    <div><br />
                        <div class="close-container"><a class="close" onclick="hide('#student')"></a></div>
                        <div class="modal-body">
                            <span>专业</span>
                            <select onchange="lookStudent();" id="majorNo">
                                <option>全部</option>
                                <#if major?exists>
                                <#list major as r> 
                                <option value="${r.majorNo!}">${r.majorName!}</option>
                                </#list>
                                </#if>
                            </select>
                            <span>入学年份</span>
                            <select onchange="lookStudent();" id="startDate">
                                <option>全部</option>
                                <option>2013</option>
                                <option>2014</option>
                                <option>2015</option>
                                <option>2016</option>
                            </select>
                            <table class="stu_1">
                                <thead>
                                    <tr>
                                        <td><input type="checkbox" id="checkstudent" onchange="checkAll(this, _select + '.stu_1')"></td> 
                                        <td>学号</td>
                                        <td>护照号</td>
                                        <td>名</td>
                                        <td>姓</td>
                                        <td>专业</td> 
                                        <td>入学年份</td>
                                    </tr>
                                </thead>
                                <tbody>
                                    <#if student?exists>
                                    <#list student as r>
                                    <tr>
                                        <td><input type="checkbox" value="${r.passportNo}" newPpn="${r.sNo!}" id="studentCheck${r_index}" name="studentCheck" onchange="alterStu(this);"></td>
                                        <td>${r.sNo!}</td>
                                        <td>${r.newpassportNo}</td>
                                        <td>${r.firstName}</td>
                                        <td>${r.lastName}</td>
                                        <td>${r.majorName}</td>
                                        <td>${r.eduStartDate}</td>
                                    </tr>
                                    </#list>
                                    </#if>
                                </tbody>
                            </table>
                            <button  onclick="fromDictToString(_selectstudent,_stuPasspordNo,_count);hide('#student');">确定</button>
                        </div>
                    </div>
                </div>
            </div>
            <!--student end-->
        </div>
        <div id="mask"></div>
		
        <!--header-->
        <div id="header"></div>
        <div id="main">
            <div id="side-menu"></div>
            <div id="container">
                <div id="currentTermContainer" style="margin:30px 0 -19px 25px;">
                    &gt;&gt;当前学期：
                    <#if allTerm?exists>
                    <#list allTerm as r> 
                    <#if r.current == 1>
                    ${r.termValue!}
                    <input id="currentTermName" type="hidden" value="${r.termValue!}">
                    <a href="${path}/adminCourseManage/addTerm" style="margin-left:10px;">新增学期</a>
                    <#elseif r.invalid == 0>
                    <input id="newTermName" type="hidden" value="${r.termValue}">
                    <input id="newTermId" type="hidden" value="${r.id}">
                    </#if>
                    </#list>
                    </#if>
                    <span style="margin-left:10px; color: red;">${message!}</span>
                </div>
                <div id="inner-border">
                    <form action="${path}/adminCourseManage/setMajor" method="POST" name="form1" id="form1" style="display: inline">
                        学期
                        <select name="term" id="term" onchange="document.form1.submit();">
                            <#if allTerm?exists>
                            <#list allTerm as r> 
                            <option>${r.termValue!}</option>
                            </#list>
                            </#if>	    
                        </select>
                    </form>
                    <button id="setCurrentButton" class="hide" onclick="setCurrent($('#newTermId').val())" style="width:110px;">设为当前学期</button>
                    <table>
                        <tr>
                            <th>专业</th>
                        </tr>
                        <#if major?exists>
                        <#list major as r> 
                        <tr>
                            <td id="${r.majorNo}"  onclick="getMajorNo(this);setMajor();show('#above-mask, #mask, #kb-container');load1();" style="cursor: pointer;">${r.majorName}</td>				
                        </tr>
                        </#list>
                        <#else>
                        <tr>
                            <td>请先将基础信息导入后再来新建课表</td>
                        </tr>
                        </#if>
                        <input type="hidden" id="majorName" value="">
                        <input type="hidden" id="majorNameXX" value="">
                    </table>
                </div>
            </div>
        </div>
                <div id="footer"></div>
        <script type="text/javascript" src="${path}/js/admin-main-appearance.js"></script>

        <!-- DataTables JavaScript -->
        <script src="${path}/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetHiddenNodes.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetTd.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetTds.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetColumnData.js"></script>
        <script src="${path}/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>

        <script type="text/javascript">
                                function getMajorNo(obj) {
                                    document.getElementById("majorName").value = obj.id;
                                    document.getElementById("majorNameXX").value = obj.innerHTML;
                                }

                                function lookCourse() {

                                    var collegeCode = document.getElementById("collegeCode").value;

                                    $.ajax({
                                        async: false,
                                        type: "POST",
                                        url: "${path}/adminCourseManage/lookCourse",
                                        dataType: "json",
                                        data: {
                                            collegeCode: collegeCode,
                                        },
                                        success: function (data) {
                                        	
                                            getCourse(data);
                                        },
                                        error: function (err) {
                                            alert("获取该专业课程失败");
                                        },
                                    });
                                }

                                function getCourse(data) {
                                    $("#courseName").empty();
                                    for (var i = 0; i < data.length; i++) {
                                        $('#courseName').append('<option value="' + data[i].courseNo + '">' + data[i].courseName + '</option>');
                                    }

                                }

                                function lookTeacher() {

                                    var collegeCode = document.getElementById("college").value;
                                    $.ajax({
                                        async: false,
                                        type: "POST",
                                        url: "${path}/adminCourseManage/lookTeacher",
                                        dataType: "json",
                                        data: {
                                            collegeCode: collegeCode,
                                        },
                                        success: function (data) {
                                      //alert(JSON.stringify(data));
                                            $(_select + '.ter_1').dataTable().fnClearTable();
                                            for (var i = 0; i < data.length; i++) {
                                                $(_select + '.ter_1').dataTable().fnAddData(['<input id="teacherCheck0" type="checkbox" value="' + data[i]["tName"] + '" name="teacherCheck">', data[i]["tNo"], data[i]["tName"], data[i]["collegeName"], data[i]["title"]]);
                                                var ot = $(_select + '.ter_1').dataTable();
                                            }
                                        },
                                        error: function (err) {
                                            alert("获取该学院教师失败");
                                        },
                                    });
                                }
                                
                                function lookAssistant() {

                                    var collegeCode = document.getElementById("as_college").value;
                                    $.ajax({
                                        async: false,
                                        type: "POST",
                                        url: "${path}/adminCourseManage/lookTeacher",
                                        dataType: "json",
                                        data: {
                                            collegeCode: collegeCode,
                                        },
                                        success: function (data) {
                                      //alert(JSON.stringify(data));
                                            $(_select + '.ass_1').dataTable().fnClearTable();
                                            for (var i = 0; i < data.length; i++) {
                                                $(_select + '.ass_1').dataTable().fnAddData(['<input id="teacherCheck0" type="checkbox" value="' + data[i]["tName"] + '" name="teacherCheck">', data[i]["tNo"], data[i]["tName"], data[i]["collegeName"], data[i]["title"]]);
                                                var ot = $(_select + '.ass_1').dataTable();
                                            }
                                        },
                                        error: function (err) {
                                            alert("获取该学院助教失败");
                                        },
                                    });
                                }

                                function lookClassroom() {

                                    var classroomType = document.getElementById("classroomType").value;
                                    $.ajax({
                                        async: false,
                                        type: "POST",
                                        url: "${path}/adminCourseManage/lookClassroom",
                                        dataType: "json",
                                        data: {
                                            classroomType: classroomType,
                                        },
                                        success: function (data) {
                                            $(_select + '.loc_1').dataTable().fnClearTable();
                                            for (var i = 0; i < data.length; i++) {
                                                $(_select + '.loc_1').dataTable().fnAddData(['<input id="classroomCheck0" type="radio" value="' + data[i]["classroomNo"] + '" name="classroomCheck">', data[i]["classroomNo"], data[i]["classroomVolume"], data[i]["examVolume"], data[i]["classroomType"]]);
                                                var ot = $(_select + '.loc_1').dataTable();
                                            }
                                            decorateTd(_select + '.loc_1');
                                        },
                                        error: function (err) {
                                            alert("获取该类型教室失败");
                                        },
                                    });
                                }

                                function lookStudent() {

                                    var startDate = document.getElementById("startDate").value;
                                    var majorNo = document.getElementById("majorNo").value;

                                    $.ajax({
                                        async: false,
                                        type: "POST",
                                        url: "${path}/adminCourseManage/lookStudent",
                                        dataType: "json",
                                        data: {
                                            startDate: startDate,
                                            majorNo: majorNo,
                                        },
                                        success: function (data) {
                                        //alert(JSON.stringify(data));
                                            $(_select + '.stu_1').dataTable().fnClearTable();
                                            for (var i = 0; i < data.length; i++) {
                                                $(_select + '.stu_1').dataTable().fnAddData(['<input id="studentCheck0" type="checkbox" newPpn="'+data[i]["sNo"]+'" value="' + data[i]["passportNo"] + '" name="studentCheck" onclick="alterStu(this);">', data[i]["sNo"], data[i]["newpassportNo"], data[i]["firstName"], data[i]["lastName"], data[i]["majorName"], data[i]["eduStartDate"]]);
                                                var ot = $(_select + '.stu_1').dataTable();
                                            }
                                            checkChecked(_select + '.stu_1');
                                        },
                                        error: function (err) {
                                            alert("获取该专业入学年份的学生失败");
                                        },
                                    });
                                }
        </script>
        <script>
            /*显示datable*/

            function load1() {

                var term = "${term!}";

                if (term != "") {
                    var select1 = document.getElementById("term");
                    select1.value = term;
                    if ($("#newTermName").val() == term)
                        $("#setCurrentButton").css("display", "inline");
                    else if ($("#currentTermName").val() != term) {
                        $("button").addClass("disabled").removeAttr("onclick");
                    }
                } else
                {
                    document.form1.submit();
                }

            }
            function setCurrent(_id) {
                var r = confirm("设置为新学期后,之前的学期信息将不能修改，此行为不可撤销，是否确定？");
                if (r == true)
                {
                    window.location.href = "${path}/adminCourseManage/setCurrentTerm?term=" + _id;
                }
            }
//            /*checkbox的全选*/
//            function checkAll(obj) {
//                var check1 = document.getElementById("check" + obj);
//                var itemsElement = document.getElementsByName(obj + "Check");
//                //alert(itemsElement.length);
//                for (var i = 0; i < itemsElement.length; i++) {
//
//                    if (check1.checked) {
//                        itemsElement[i].checked = "checked";
//                    } else {
//                        itemsElement[i].checked = null;
//                    }
//                }
//            }

            window.onload = load1();
        </script>
        <script src="${path}/js/setMajor2.js"></script>
    </body>
</html>
